home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
BUSINESS
/
STATA3.LZH
/
GRAPHKIT.TUT
< prev
next >
Wrap
Text File
|
1988-08-29
|
9KB
|
271 lines
set output error
set display page 23
set more 1
#delimit ;
di _n(13) in wh
" ___ ____ ____ ____ ____ tm" _n
" /__ / ____/ / ____/" _n
"___/ / /___/ / /___/ Graph.Kit: Programmed Extensions to Stata" _n
"--------------------------------------------------------------------------"
_n(2) ;
di in gr
"Graph.Kit is a collection of programs written in Stata that provides a conven-"
_n
"ient way of creating a variety of statistical graphs. Although Graph.Kit is"
_n
"written in Stata's programming language, you do not have to know anything" _n
"about the programming language to use Graph.Kit." _n ;
di in gr
"If your computer and monitor do not have graphics capabilities, there is no" _n
"reason to run this tutorial. You can still use Stata's graphics, but you will"
_n
"have to print them in order to see them. This tutorial assumes that you will"
_n
"be able to see the graphs as we draw them. You can abort this tutorial by" _n
"pressing "
in wh "Break"
in gr " (DOS users hold down "
in wh "Ctrl" in gr " and press " in wh "Break"
in gr ", Unix users hold down"
_n
in wh "Ctrl" in gr " and press " in wh "C"
in gr "). On the next screen, we will verify that Stata thinks your"
_n
"computer has graphics capabilities." _n ;
di in gr
"If you are using a Sun under SunView, please "
in wh "Break" in gr" out of this tutorial, type"
_n
"'" in wh "window define tut"
in gr "', and then restart this tutorial. You don't have to do" _n
"that, but results will be better if you do. (You may have already done this"
_n
"when you ran the graphics tutorial. If so, you don't need to do it again.)"
_n ;
#delimit cr
mac def path
capture run nullfile.tut
if _rc {
mac def path "\stata\"
capture run %path`nullfile.tut
if _rc {
mac def path "/usr/stata/"
capture run %path`nullfile.tut
if _rc {
#delimit ;
di in red
"I cannot find the other tutorial files. I have looked in the current" _n
"directory and in \stata (DOS) or /usr/stata (Unix). Is Stata installed" _n
"correctly?" _n(2)
"In any case, I cannot run the tutorial." ;
#delimit cr
exit
}
}
}
macro define F5 "do %path`contents.tut;"
macro define F6 "do %path`datakit.tut;"
drop _all
label drop _all
set textsize 100
if "%path"=="/usr/stata/" {
mac def _pause "more"
}
#delimit ;
set more 0 ; more ; set more 1 ;
di _n(4) in wh
"More preliminary" _n
"----------------" _n(2)
". query" ;
noisily query ;
di in gr _n
"If the above display indicates that "
in wh "graphics" in gr " are " in wh "off"
in gr ", Stata does not think" _n
"your computer and monitor have graphics capabilities, so you may as well" _n
in wh "Break" in gr " out of this tutorial." _n ;
set more 0 ; more ; set more 1;
macro define F6 "do %path`graphkit.tut;" ;
di _n(10) in wh
"Loading Graph.Kit" _n
"-----------------" _n ;
di _n(2) in wh _dup(79) "-" _n in gr
"Before you can use Graph.Kit, you must load it:" _n
in wh _dup(79) "-" _n(4)
". run %path`Graph.Kit" ;
run %path`Graph.Kit ;
di _n ; set more 0 ; more ; set more 1 ;
di _n(2) in wh
"Overview" _n
"--------" _n ;
di in gr
"Graph.Kit adds seven new commands to Stata:" _n(2)
_col(8) in wh "grebar" _col(20) in gr "error-bar chart" _n
_col(8) in wh "leverage" _col(20) in gr "partial-regression leverage plot" _n
_col(8) in wh "quantile" _col(20) in gr "quantile plot" _n
_col(8) in wh "qnorm" _col(20) in gr "quantile-normal plot" _n
_col(8) in wh "qqplot" _col(20) in gr "quantile-quantile plot" _n
_col(8) in wh "symplot" _col(20) in gr "symmetry plot" _n ;
di in gr
"We were forced to omit the "
in wh "grebar" in gr " command from the demonstration version of" _n
"Graph.Kit. During the process of making its calculations, "
in wh "grebar" in gr " writes a" _n
"temporary data set, something the demonstration version of Stata cannot do."
_n
"If you attempt to use "
in wh "grebar" in gr ", you will get the message '" in ye "not available in" _n
"demonstration version" in gr "'." _n(2)
"If you are using the Unix version of Stata in demonstration mode, do not use"
_n
"the "
in wh "grebar" in gr
" command. Your version of Graph.Kit contains the real " in wh "grebar" _n
in gr
"program, but it will not work in demonstration mode." _n(3) ;
set more 0 ; more ; set more 1 ;
di _n(2) in wh _dup(79) "-" _n in gr
"We begin by using our automobile data, the same data we used in the introduc-"
_n
"tion. We only need a few of the variables:" _n
in wh _dup(79) "-" _n(2)
". use %path`auto, clear" ;
use %path`auto, clear ;
di _n in wh ". keep make price mpg weight displ foreign" _n(2)
". describe" ;
keep make price mpg weight displ foreign;
noisily describe ;
di _n in wh ". list in 1/20" ;
set more 0 ; more ; set more 1 ;
noisily list in 1/20 ;
set more 0 ; more ; set more 1 ;
di _n(17) in wh _dup(79) "-" _n
"hilite" in gr
" is a convenient command for drawing two-way scatterplots and highlight-"
_n
"ing a subset of the data. Its syntax is the same as "
in wh "graph" in gr "'s " in wh "twoway" in gr " syntax,"
_n
"except that you must specify the group to be highlighted:" _n
in wh _dup(79) "-" _n(2)
". hilite mpg displ, hilite(foreign) ylabel xlabel" ;
set more 0 ; more ;
hilite mpg displ, hilite(foreign) ylabel xlabel sy(pO) gap(5) ;
%_pause ; set more 1 ;
di _n(2) in wh _dup(79) "-" _n in gr
"The "
in wh "leverage" in gr
" command produces partial-regression leverage plots. Its syntax" _n
"is '" in wh "leverage" in gr
" lhsvar rhsvar1 rhsvar2 rhsvar3 ...'. The command graphs lhsvar" _n
"against rhsvar1 after making them orthogonal to rhsvar2, rhsvar3, and so on."
_n(2)
"Consider the model" _n(2)
_col(8) "mpg = b + b displ + b weight + b foreign" _n
_col(8) " 0 1 2 3" _n ;
di in gr
"To obtain the regression estimates, we could type '"
in wh "regress mpg displ weight" _n
"foreign" in gr "' or '" in wh
"regress mpg foreign weight displ" in gr "' -- the order of the right-hand-"
_n
"side variables makes no difference -- it is still the same model. To obtain"
_n
"the partial-regression leverage plot for weight -- corresponding to b2 -- we"
_n
"type either '"
in wh "leverage mpg weight foreign displ" in gr "' or '" in wh
"leverage mpg weight displ"
_n
"foreign" in gr "
' -- we must make weight the first right-hand-side variable." _n(2)
"To obtain the leverage plot for foreign -- corresponding to b3 -- we could" _n
"type:" _n
in wh _dup(79) "-" _n(3)
". leverage mpg foreign displ weight" ;
set more 0 ; more ;
leverage mpg foreign displ weight ;
%_pause ; set more 1 ;
di _n(2) in wh _dup(79) "-" _n in gr
"We are sometimes interested in whether a variable has a symmetric "
"distribution." _n
"Symmetry plots focus on this aspect of a distribution." _n(2)
"The most expensive car in our 1978 automobile data costs "
in ye "$15,906" in gr "; the least" _n
"expensive costs " in ye "$3,291" in gr
". Let's compare these two cars with the typical car in" _n
"the data, comparing how much more it costs to buy the most expensive car with"
_n
"how much less it costs to buy the least expensive. If the automobile price" _n
"distribution is symmetric, the price differences would be almost the same."
_n ;
di in gr
"The price of the median car in our data is "
in ye "$5,006.50" in gr ", so the most expensive"
_n
"car costs "
in ye "$10,899.50" in gr
" more than the median car and the least expensive costs" _n
in ye "$1,715.50" in gr
" less than the median car. We now have one piece of evidence that"
_n
"the distribution is not symmetric." _n ;
di in gr
"We could repeat the calculation for the second most expensive car and the sec-"
_n
"ond least expensive car, then for the third, and so on. "
in wh "symplot" in gr" makes these"
_n
"calculations and graphs the result:" _n
in wh _dup(79) "-" _n(5)
". symplot price" ;
set more 0 ; more ;
symplot price ;
%_pause ; set more 1 ;
drop _all ;
label drop _all ;
macro define F6 "do %path`datakit.tut;" ;
di _n(4) in white
"Demonstration ends" _n
"------------------" _n ;
di in green
"That concludes our short demonstration, but there's much more. We now return"
_n
"control to you. Some suggestions:" _n ;
di in green
"If you ..." _col(34) "Then we will show you ..." _n
" Press " in white "F5" in green _col(38) "a table of tutorial contents" _n
" Press " in white "F6" in green _col(38) "the next tutorial, "
in white "datakit.tut" _n ;
run %path`tobuy.tut ;